package com.xilihui.xlh.core.util;


import org.greenrobot.eventbus.EventBus;

import java.util.Arrays;


public class YEventBuses {

	public static void register(Object object){
		EventBus.getDefault().register(object);
	}
	public static void unregister(Object object){
		EventBus.getDefault().unregister(object);
	}
	public static void post(Event event){
		EventBus.getDefault().post(event);
	}


	public static class Event {

		private String source;

		public String getSource() {
			return source;
		}

		public Event() {
		}

		public Event(String source) {
			this.source = source;
		}

		public void setSource(String source) {
			this.source = source;
		}

		Object[] params;

		public Object getParams(int index) {
			if (params == null) {
				return null;
			}
			return params[index];
		}

		public Event setParams(Object... params) {
			this.params = params;
			return this;
		}

		public boolean is(String source) {

			return this.source.equals(source);
		}

		@Override
		public String toString() {
			return "Event [source=" + source + ", params="
					+ Arrays.toString(params) + "]";
		}
	}
}
